<%--
  Created by IntelliJ IDEA.
  User: bbb
  Date: 2025/3/24
  Time: 14:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>评论列表</title>
</head>
<body>
<h1>评论列表</h1>
<c:if test="${empty comments}">
    <p>还没有进行任何评论。</p>
</c:if>
<c:if test="${not empty comments}">
    <ul>
        <c:forEach var="comment" items="${comments}">
            <li>
                <strong>${comment.user}</strong>: ${comment.content} <br/>
                <small>评论时间: ${comment.timestamp}</small>
            </li>
        </c:forEach>
    </ul>
</c:if>
</body>
<script>
    // 判断用户是否为空
    if (${empty user}) {
        if (window.top !== window.self) {
            window.top.location.href = '${pageContext.request.contextPath}/luyou/login'; // 跳出 iframe 并跳转到登录页面
        } else {
            window.location.href = '${pageContext.request.contextPath}/luyou/login'; // 直接跳转到登录页面
        }
    }
</script>
</html>
